Interval List Intersections
Question
Given two non-overlappinglists of intervals, return a new list of intervals which are intersections of the two lists.
The lists given to you are already sorted by their the intervals' first value.
The intervals' first value is always less than or equal to its second value.
Input: list_a = [[0, 3], [4, 5], [6, 7]], list_b = [[1, 2], [7, 7]]
Output: [[1, 2], [7, 7]]
Intervals [0, 3] and [1, 2] intersect at [1, 2] and intervals [6, 7] and [7, 7] intersect at [7, 7].
Input: list_a = [[3, 3], [4, 6], [7, 7]], list_b = [[1, 5]]
Output: [[3, 3], [4, 5]]
None of the intervals intersect since the second list is empty.
Input: list_a = [[0, 3], [4, 5], [6, 7]], list_b = []
Output: []
None of the intervals intersect since the second list is empty.
Clarify the problem
What are some questions you'd ask an interviewer?
Understand the problem
Login or signup to save your code.
Uh oh... looks like you don't yet have access.
Not sure what this unlocks? Check out a free pattern section.